home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / term41source.lha / Extras / Source / term-Source.lha / ClipPanel.c < prev    next >
C/C++ Source or Header  |  1994-07-30  |  6KB  |  289 lines

  1. /*
  2. **    ClipPanel.c
  3. **
  4. **    Editing panel for clipboard configuration
  5. **
  6. **    Copyright © 1990-1994 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_UNIT=1000,GAD_USE,GAD_CANCEL,GAD_DEFAULT };
  13.  
  14. STATIC STRPTR __saveds
  15. ShowTime(struct Gadget *SomeGadget,WORD Level)
  16. {
  17.     return(LocaleSeconds(Level));
  18. }
  19.  
  20. BYTE __regargs
  21. ClipPanel(struct Configuration *Config,BYTE *Default)
  22. {
  23.     struct LayoutHandle    *Handle;
  24.     BYTE             Cancel = FALSE;
  25.  
  26.     SaveConfig(Config,PrivateConfig);
  27.  
  28.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  29.         LH_LocaleHook,    &LocaleHook,
  30.     TAG_DONE))
  31.     {
  32.         struct Window *PanelWindow;
  33.  
  34.         LT_New(Handle,
  35.             LA_Type,    VERTICAL_KIND,
  36.         TAG_DONE);
  37.         {
  38.             LT_New(Handle,
  39.                 LA_Type,    VERTICAL_KIND,
  40.                 LA_LabelID,    MSG_V36_0019,
  41.             TAG_DONE);
  42.             {
  43.                 LT_New(Handle,
  44.                     LA_Type,        INTEGER_KIND,
  45.                     LA_LabelID,        MSG_CLIPPANEL_UNIT_GAD,
  46.                     LA_WORD,        &Config -> ClipConfig -> ClipboardUnit,
  47.                     LA_Chars,        20,
  48.                     LAIN_Min,        0,
  49.                     LAIN_Max,        255,
  50.                     LA_ID,            GAD_UNIT,
  51.                     LAIN_UseIncrementers,    TRUE,
  52.                     GTIN_MaxChars,        3,
  53.                 TAG_DONE);
  54.  
  55.                 LT_New(Handle,
  56.                     LA_Type,    STRING_KIND,
  57.                     LA_LabelID,    MSG_CLIPPANEL_PASTE_PREFIX_GAD,
  58.                     LA_STRPTR,    Config -> ClipConfig -> InsertPrefix,
  59.                     GTST_MaxChars,    79,
  60.                 TAG_DONE);
  61.  
  62.                 LT_New(Handle,
  63.                     LA_Type,    STRING_KIND,
  64.                     LA_LabelID,    MSG_CLIPPANEL_PASTE_SUFFIX_GAD,
  65.                     LA_STRPTR,    Config -> ClipConfig -> InsertSuffix,
  66.                     GTST_MaxChars,    79,
  67.                 TAG_DONE);
  68.  
  69.                 LT_EndGroup(Handle);
  70.             }
  71.  
  72.             LT_New(Handle,
  73.                 LA_Type,    VERTICAL_KIND,
  74.                 LA_LabelID,    MSG_V36_0020,
  75.             TAG_DONE);
  76.             {
  77.                 LT_New(Handle,
  78.                     LA_Type,    VERTICAL_KIND,
  79.                 TAG_DONE);
  80.                 {
  81.                     LT_New(Handle,
  82.                         LA_Type,    CYCLE_KIND,
  83.                         LA_LabelID,    MSG_CLIPPANEL_TEXT_PACING_GAD,
  84.                         LA_UBYTE,    &Config -> ClipConfig -> PacingMode,
  85.                         LACY_FirstLabel,MSG_CLIPPANEL_DIRECT_TXT,
  86.                         LACY_LastLabel,    MSG_CLIPPANEL_KEYDELAY_TXT,
  87.                     TAG_DONE);
  88.  
  89.                     LT_EndGroup(Handle);
  90.                 }
  91.  
  92.                 LT_New(Handle,
  93.                     LA_Type,    VERTICAL_KIND,
  94.                     LA_LabelID,    MSG_V36_0021,
  95.                 TAG_DONE);
  96.                 {
  97.                     LT_New(Handle,
  98.                         LA_Type,        SLIDER_KIND,
  99.                         LA_LabelID,        MSG_CLIPPANEL_CHAR_DELAY_GAD,
  100.                         GTSL_Min,        0,
  101.                         GTSL_Max,        10 * 100,
  102.                         LA_Chars,        10,
  103.                         LA_WORD,        &Config -> ClipConfig -> CharDelay,
  104.                         GTSL_LevelFormat,    "%s s",
  105.                         GTSL_DispFunc,        ShowTime,
  106.                     TAG_DONE);
  107.     
  108.                     LT_New(Handle,
  109.                         LA_Type,        SLIDER_KIND,
  110.                         LA_LabelID,        MSG_CLIPPANEL_LINE_DELAY_GAD,
  111.                         GTSL_Min,        0,
  112.                         GTSL_Max,        10 * 100,
  113.                         LA_Chars,        10,
  114.                         LA_WORD,        &Config -> ClipConfig -> LineDelay,
  115.                         GTSL_LevelFormat,    "%s s",
  116.                         GTSL_DispFunc,        ShowTime,
  117.                     TAG_DONE);
  118.  
  119.                     LT_EndGroup(Handle);
  120.                 }
  121.  
  122.                 LT_New(Handle,
  123.                     LA_Type,    VERTICAL_KIND,
  124.                     LA_LabelID,    MSG_V36_0024,
  125.                 TAG_DONE);
  126.                 {
  127.                     LT_New(Handle,
  128.                         LA_Type,        STRING_KIND,
  129.                         LA_LabelID,        MSG_CLIPPANEL_LINE_PROMPT_GAD,
  130.                         LA_STRPTR,        Config -> ClipConfig -> LinePrompt,
  131.                         LA_Chars,        10,
  132.                         GTST_MaxChars,        255,
  133.                     TAG_DONE);
  134.  
  135.                     LT_New(Handle,
  136.                         LA_Type,        SLIDER_KIND,
  137.                         LA_LabelID,        MSG_CLIPPANEL_SEND_TIMEOUT_GAD,
  138.                         GTSL_Min,        0,
  139.                         GTSL_Max,        10 * 100,
  140.                         LA_WORD,        &Config -> ClipConfig -> SendTimeout,
  141.                         GTSL_LevelFormat,    "%s s",
  142.                         GTSL_DispFunc,        ShowTime,
  143.                     TAG_DONE);
  144.  
  145.                     LT_EndGroup(Handle);
  146.                 }
  147.  
  148.                 LT_EndGroup(Handle);
  149.             }
  150.  
  151.             LT_New(Handle,
  152.                 LA_Type,VERTICAL_KIND,
  153.             TAG_DONE);
  154.             {
  155.                 LT_New(Handle,
  156.                     LA_Type,    XBAR_KIND,
  157.                     LAXB_FullSize,    TRUE,
  158.                 TAG_DONE);
  159.  
  160.                 LT_EndGroup(Handle);
  161.             }
  162.  
  163.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  164.                 LAGR_SameSize,    TRUE,
  165.                 LAGR_Spread,    TRUE,
  166.             TAG_DONE);
  167.             {
  168.                 LT_New(Handle,
  169.                     LA_Type,    BUTTON_KIND,
  170.                     LA_LabelID,    MSG_GLOBAL_USE_GAD,
  171.                     LA_ID,        GAD_USE,
  172.                     LABT_ReturnKey,    TRUE,
  173.                     LABT_ExtraFat,    TRUE,
  174.                 TAG_DONE);
  175.  
  176.                 if(Default)
  177.                 {
  178.                     LT_New(Handle,
  179.                         LA_Type,    BUTTON_KIND,
  180.                         LA_LabelID,    MSG_GLOBAL_DEFAULT_GAD,
  181.                         LA_ID,        GAD_DEFAULT,
  182.                         LABT_ExtraFat,    TRUE,
  183.                     TAG_DONE);
  184.                 }
  185.  
  186.                 LT_New(Handle,
  187.                     LA_Type,    BUTTON_KIND,
  188.                     LA_LabelID,    MSG_GLOBAL_CANCEL_GAD,
  189.                     LA_ID,        GAD_CANCEL,
  190.                     LABT_EscKey,    TRUE,
  191.                     LABT_ExtraFat,    TRUE,
  192.                 TAG_DONE);
  193.  
  194.                 LT_EndGroup(Handle);
  195.             }
  196.  
  197.             LT_EndGroup(Handle);
  198.         }
  199.  
  200.         if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_CLIPPANEL_CLIP_SETTINGS_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
  201.             LAWN_HelpHook,        &GuideHook,
  202.             LAWN_Parent,        Window,
  203.             WA_DepthGadget,        TRUE,
  204.             WA_CloseGadget,        TRUE,
  205.             WA_DragBar,        TRUE,
  206.             WA_RMBTrap,        TRUE,
  207.             WA_Activate,        TRUE,
  208.         TAG_DONE))
  209.         {
  210.             struct IntuiMessage    *Message;
  211.             BOOLEAN             Done = FALSE;
  212.             ULONG             MsgClass,
  213.                          MsgQualifier;
  214.             UWORD             MsgCode;
  215.             struct Gadget        *MsgGadget;
  216.  
  217.             GuideContext(CONTEXT_CLIP);
  218.  
  219.             PushWindow(PanelWindow);
  220.  
  221.             LT_ShowWindow(Handle,TRUE);
  222.  
  223.             do
  224.             {
  225.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  226.                 {
  227.                     SaveConfig(PrivateConfig,Config);
  228.  
  229.                     break;
  230.                 }
  231.  
  232.                 while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
  233.                 {
  234.                     MsgClass    = Message -> Class;
  235.                     MsgQualifier    = Message -> Qualifier;
  236.                     MsgCode        = Message -> Code;
  237.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  238.  
  239.                     GT_ReplyIMsg(Message);
  240.  
  241.                     LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  242.  
  243.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  244.                     {
  245.                         SaveConfig(PrivateConfig,Config);
  246.  
  247.                         Done = TRUE;
  248.                     }
  249.  
  250.                     if(MsgClass == IDCMP_GADGETUP)
  251.                     {
  252.                         switch(MsgGadget -> GadgetID)
  253.                         {
  254.                             case GAD_USE:
  255.  
  256.                                 Done = TRUE;
  257.                                 break;
  258.  
  259.                             case GAD_CANCEL:
  260.  
  261.                                 SaveConfig(PrivateConfig,Config);
  262.  
  263.                                 Cancel = Done = TRUE;
  264.                                 break;
  265.  
  266.                             case GAD_DEFAULT:
  267.  
  268.                                 *Default = TRUE;
  269.  
  270.                                 Done = TRUE;
  271.                                 break;
  272.                         }
  273.                     }
  274.                 }
  275.             }
  276.             while(!Done);
  277.  
  278.             PopWindow();
  279.         }
  280.  
  281.         LT_DeleteHandle(Handle);
  282.     }
  283.  
  284.     if(Default)
  285.         return((BYTE)(!Cancel));
  286.     else
  287.         return((BYTE)memcmp(PrivateConfig -> ClipConfig,Config -> ClipConfig,sizeof(struct ClipSettings)));
  288. }
  289.